﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<WebClient.Models.ViewModels.GroupViewModel>" %>

<table cellpadding="0" cellspacing="0" style="width:100%" >
    <tr>
		<td style="background-image:url(../../Content/Images/Admin/backgr.gif); height:60px; text-align:center">
            <a href="<%= Url.Action("Index", "Home") %>" style="text-decoration: none;">
                <span style="color: #cc0000; font-size: 25px; font-weight: bold; "><%= WebConfiguration.SiteName %></span>
            </a>
        </td>
	</tr>
	<tr>
		<td style="height:1px; background-color:#484883"></td>
	</tr>
                		
	<tr>
		<td style="vertical-align:top; padding:0px;">
			<%--<div id="lefttreeholder" class="dtree" style="width:300px; height:300px; margin:2px 0 0 5px; overflow:auto">
			<div style="width:600px">--%>
			<div style="margin:5px;">

				<script type="text/javascript">
					//<!--
					//<%--(id, pid, name, url, title, target, icon, iconOpen, open) --%>
					d = new dTree('d');
					d.add(0, -1, ' Administration&nbsp;(<a href="javascript: d.openAll();"><u>expand all</u></a>&nbsp;<a href="javascript: d.closeAll();"><u>collapse all</u></a>)');
					<% 
                        // Get role for user
                        HttpCookie SlmMemberCookie = new HttpCookie("SLMFRole");
                        SlmMemberCookie = HttpContext.Current.Request.Cookies["SLMFRole"];
                        string role = "";
                        if (SlmMemberCookie != null && SlmMemberCookie.Value != "" &&
                             SlmMemberCookie.Value != null)
                        {
                            role = SlmMemberCookie.Value.ToString();
                        }

                        if(role.ToUpper() == "ADMIN")
                        {
                        %>
                            d.add(1, 0, 'FoodType', '../Admin/SelectFoodType');
                            d.add(2, 0, 'City', '../Admin/SelectCity'); 
                            <%
                            var lstCity = Model.CityModel.GetModel.LstObjModel;
                            for (int i = 0; i < lstCity.Count; i++){ %>
                            // CITY
                            d.add(2<%= i %>, 2, '<%= lstCity[i].Name %>', '../Admin/SelectDistrictByIDCity?idcity=<%= lstCity[i].ID %>');
                            <% 
                               var lstDistrict = lstCity[i].Districts;
                               for (int j = 0; j < lstDistrict.Length; j++){ 
                            %>
                                // DISTRICT OF CITY
                                d.add(2<%= i %><%= j %>, 2<%= i %>, '<%= lstDistrict[j].Name %>', '');
                                <% 
                                    var lstFoodType = Model.FoodTypeModel.GetModel.LstObjModel;
                                    for (int k = 0; k < lstFoodType.Count; k++){ %>
                                    // FOOD TYPE
                                    d.add(2<%= i %><%= j %><%= k %>, 2<%= i %><%= j %>, '<%= lstFoodType[k].Name %>', '../Admin/SelectRestaurantByIDDistrictAndIDFoodType?iddistrict=<%= lstDistrict[j].ID %>&idfoodtype=<%= lstFoodType[k].ID %>');
                                     <%
                                        var lstRestaurant = lstDistrict[j].Restaurants.Where(n => n.IDFoodType == lstFoodType[k].ID).ToList();
                                        for (int p = 0; p < lstRestaurant.Count; p++){ 
                                     %>
                                        // RESTAURANT
                                        d.add(2<%= i %><%= j %><%= k %><%= p %>, 2<%= i %><%= j %><%= k %>, '<%= lstRestaurant[p].Name %>', '../Admin/SelectManager?idrestaurant=<%= lstRestaurant[p].ID %>');
                                        <%
                                        }
                                        %>
                                <% } %>
                            <% } %>
                        <% } %>
                        d.add(3, 0, 'Orders', '../../Admin/AdminSelectOrders');
                        d.add(4, 0, 'Users', '../Admin/SelectUsers');
                        d.add(5, 0, 'Contact', '../Admin/SelectContact');
                        d.add(6, 0, 'Information', '../Admin/SelectInformationWeb');
                     <% }
                        else if(role.ToUpper() == "MANAGER")
                        { %>
                            // RESTAURANT
                            <%
                            var restaurant = Model.RestaurantModel.GetModel.LstObjModel[0];
                             %>
                            d.add(1, 0, '<%= restaurant.Name %>', '../../Admin/DetailOfRestaurant?id=<%= restaurant.ID %>');
                            d.add(2, 1, 'Menus', 'SelectMenuByIDRestaurant?idrestaurant=<%= restaurant.ID %>');
                            <%
                                var lstMenu = restaurant.Menus;
                                for (int i = 0; i < lstMenu.Length; i++){ 
                                %>
                                    // MENU
                                    d.add(2<%= i %>, 2, '<%= lstMenu[i].Name %>', '../../Admin/SelectFoodByIDMenu?idmenu=<%= lstMenu[i].ID %>&idrestaurant=<%= restaurant.ID %>');
                                <%
                                }
                                %>
                            d.add(3, 0, 'Orders', '../../Admin/SelectOrdersByIDRestaurant?idrestaurant=<%= restaurant.ID %>');
                            d.add(4, 0, 'Revenue', '../../Admin/Revenue?idrestaurant=<%= restaurant.ID %>');
                     <% } %>
                   
					d.config.useLines = true;d
					document.write(d);
					//d.openAll();
					//-->
				</script>
                
			</div>				
		</td>
		<td style="background-image:url(../../Content/Images/Admin/backgr.gif); height: 23px;"></td>
	</tr>
</table>
